Page({
  data: {
    imageSrc: "http://wyeyun.oss-cn-shenzhen.aliyuncs.com/2022_05_12/23283b72-9784-0dcf-53a7-462514e8371c.jpg"
  },
  onLoad:function(options){
    console.log("index 页面 加载了,",options);
  },
  onShow:function(){
    console.log("index 页面看见了");
  },
  onReady:function(){
    console.log("页面渲染完毕了");
  },
  onHide:function(){
    console.log("页面切换到后台");
  },
  // onLoad: function () {
  //   wx.request({
  //     url: 'https://www.opposhop.cn/cn/oapi/goods/web/products/v15/040204',
  //     header: {
  //       Accept: 'application/json, text/plain, */*',
  //       'Accept-Encoding': 'gzip, deflate, br',
  //       'Accept-Language': 'zh-CN,zh;q=0.9',
  //       appId: "",
  //       appKey: "",
  //       'Cache-Control': 'no-cache',
  //       Connection: 'keep-alive',
  //       constToken: '+SeKm/zS0HpFRhBVVBaQAIoj8m7jRqYO@bj',
  //       Cookie: 'i18n_redirected=zh_CN;_ga_nefid_=fMg5nOym%2FmNFEkBEQBeBFWefsJ3rVNvD; utm_campaign=direct; utm_term=direct; cookies-tips=should_close; sa_distinct_id=WVhnL3EvNlpuZWRSNm1xRzVoeU84QT09; memberinfo=%7B%22id%22%3A%22878843849%22%2C%22name%22%3A%22%E7%94%A8%E6%88%B701787605466%22%2C%22oid%22%3A%22WVhnL3EvNlpuZWRSNm1xRzVoeU84QT09%22%7D; ut=direct; uc=direct; utm_source=opposhop; utm_medium=shouye; _dx_uzZo5y=ac0ed9928e381a3065811696bb421c035a0da57deb23eaf154a5c8067105be8a191f547e; _dx_app_900cf4f8d0fb9f215d567b1c23d1fc38=6268a9bccSWQV0Rk4HfkcoI1ufYfBXMN57NlTjx1; _dx_captcha_vid=18068D74B50900CF4F8D04B93FFC4A6DB4D3F93C174C03A510D9A%40gz; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22WVhnL3EvNlpuZWRSNm1xRzVoeU84QT09%22%2C%22%24device_id%22%3A%221805bcae5486f9-0301409b19d1dc-f791539-1327104-1805bcae5496c0%22%2C%22props%22%3A%7B%22%24latest_referrer%22%3A%22%22%2C%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_utm_source%22%3A%22opposhop%22%2C%22%24latest_utm_medium%22%3A%22shouye%22%2C%22%24latest_utm_campaign%22%3A%22direct%22%2C%22%24latest_utm_term%22%3A%22direct%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTgwNjA0NDBlZTMzMS0wZTU4MTcwOTU3NGNjNC03ZDdkMzI2ZS0yNTAxMjUtMTgwNjA0NDBlZTQ2MmQiLCIkaWRlbnRpdHlfbG9naW5faWQiOiJXVmhuTDNFdk5scHVaV1JTTm0xeFJ6Vm9lVTg0UVQwOSJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%22WVhnL3EvNlpuZWRSNm1xRzVoeU84QT09%22%7D%2C%22first_id%22%3A%22WVhnL3EvNlpuZWRSNm1xRzVoeU84QT09%22%7D; us=shouye; um=icon; acw_tc=2f6a1fe916523182553115263e1b862865aeb7176029a7fdd7bb717aa1f1d6',
  //       Host: 'www.opposhop.cn',
  //       Referer: 'https://www.opposhop.cn/cn/m/',
  //       s_channel: "h5_m",
  //       s_version: '',
  //       sa_distinct_id: 'WVhnL3EvNlpuZWRSNm1xRzVoeU84QT09',
  //       'Sec-Fetch-Dest': "empty",
  //       'Sec-Fetch-Mode': "cors",
  //       'Sec-Fetch-Site':'',
  //       'same-origin':'',
  //       source_type: 504,
  //       uc: 'direct',
  //       um: 'icon',
  //       us: 'shouye',
  //       'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',
  //       ut: 'direct',
  //       utm_campaign: 'direct',
  //       utm_medium: 'shouye',
  //       utm_source: 'opposhop',
  //       utm_term: 'direct'
  //     },
  //     data: {},
  //     success: (res) => {
  //       console.log(res);
  //     },
  //     fail: function (err) {
  //       console.log(err);
  //     },
  //     complete: function () {
  //       console.log("请求完成了");
  //     }
  //   })
  // },
  // onShow: function () {
  //   const app = getApp();
  //   console.log(app.globalData);
  //   wx.request({
  //     url: 'https://id.opposhop.cn/api/login/v1/auth',
  //     method: "POST",
  //     data: {
  //       msg: "ZEDqYRAiNkgLm8ag7p3KdKFAvf8YUMGjI+FrrZux6s99q4+kBkBji0ppOLwGhVcn7ZaiylyzHiKentxzJmNDWbxJUyoKmKGlOIbTpyOzpiEXCCIGxg0YrPHGuHGtOgaS9OjsNaYhEL9hyF5NnzZVfNm98PwjTkR4Z9Mw/qUiRy1DP+o1soed6FOr6L+I++27PDOCFWwDHmKeck98Li75BlqUAXfH0dkX0kGWBzMa442MtNZUSqdJeZRzmsfZDZi7"
  //     },
  //     success: (res) => {
  //       console.log(res);
  //     },
  //     fail: (err) => {
  //       console.log(err);
  //     },
  //     complete: () => {
  //       console.log("post 请求完成了");
  //     }
  //   })
  // },
  handleChoose: function () {
    // wx.chooseImage 选择本地的图片或者从相机里面拍照
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      // 箭头函数
      success: (res) => {
        console.log(res);
        this.setData({
          imageSrc: res.tempFilePaths[0]
        })
        wx.uploadFile({
          // 图片小程序中的临时地址
          filePath: res.tempFilePaths[0],
          name: 'file',
          /* 
          {
            file:"文件的数据"
          }
          */
          url: 'http://s.linweiqin.com/api/s/aliossUpload',
          success: (res) => {
            console.log(JSON.parse(res.data).url);
          }
        })
      },
      fail: (err) => {
        console.log(err);
      },
      complete: () => {
        console.log("完成了");
      }
    })
  },
  showLoading: function () {
    wx.showLoading({
      // mask:true,
      title: '加载中',
    });
  },
  hideLoading: function () {
    wx.hideLoading();
  },
  showModal: function () {
    wx.showModal({
      title: '提示',
      content: '这是一个模态弹窗',
      success(res) {
        if (res.confirm) {
          console.log('用户点击确定');
        } else if (res.cancel) {
          console.log('用户点击取消');
        }
      },
    });
  },
  showToast: function () {
    wx.showToast({
      title: '成功',
      icon: 'success',
      duration: 2000,
    });
  },
  showActionSheet: function () {
    wx.showActionSheet({
      itemList: ['A', 'B', 'C'],
      success(res) {
        console.log(res.tapIndex);
      },
      fail(res) {
        console.log(res.errMsg);
      },
    });
  },
  setBarTitle: function () {
    wx.setNavigationBarTitle({
      title: '设置标题',
    });
  },
  setBarLoading: function () {
    wx.showNavigationBarLoading();
  },
  cancelBarLoading: function () {
    wx.hideNavigationBarLoading();
  },
  hideTabbar: function () {
    wx.hideTabBar({
      animation: true,
    });
  },
  showTabbar: function () {
    wx.showTabBar({
      animation: true,
    });
  },
  handleSaveSync: function () {
    wx.setStorageSync('obj', {
      id: 123
    })
  },
  handleGetSync: function () {
    console.log(wx.getStorageSync('obj'))
  },
  handleSave: function () {
    // 异步存
    wx.setStorage({
      key:"id",
      data:"id",
      success:(res)=>{
        console.log(res);
      }
    });
    console.log(wx.getStorageSync('id'));
  },
  handleGet: function () {
    wx.getStorage({
      key: "id",
      success: (res) => {
        console.log(res);
      }
    })
  }
})